<template>
  <div id="fan">
    <div class="p3d">
      <photo></photo>
      <div class="text">3D相册</div>
    </div>

    <div class="canv">
      <msk class="msk"></msk>
      <div class="gua">
         <gua ></gua>
         <div class="text">揭开期待...</div>
      </div>
    </div>
     <dzk class="dzk" />
     <snoke />
     <vid></vid>
     <div class="mediaVideo" v-show="mediaShow">
       <div class="title">视频回放</div>
       <video :src="mediaSrc" controls width="400" height="180"></video>
     </div>
  </div>
</template>

<script>
import photo from "./group/3dphoto.vue";
import gua from "./group/gua.vue";
import msk from "./msk/msk.vue";
import dzk from './yx/dzk.vue'
import snoke from './yx/snoke.vue'
import vid from './video/vid.vue'
import { getCurrentInstance, onMounted, onUnmounted ,ref} from "vue";
import {useRoute} from 'vue-router'
export default {
  components: {
    photo,
    gua,
    dzk,
    snoke,
    vid,
    msk
  },

  setup() {
    let { ctx } = getCurrentInstance();
    let route=useRoute()
    onMounted(() => {
      document.onvisibilitychange = function () {
        if (!document.hidden) {
          ctx.$message({
            message:"请谨慎切屏",
            type:'warning'
          });
        }
      };
      let mediaURL=route.query.mediaURL
      if(mediaURL){
        mediaSrc.value=mediaURL
        mediaShow.value=true
      }

      ctx.$bus.off()
      ctx.$bus.on('media',(url)=>{
         mediaSrc.value=url
         mediaShow.value=true
      })
    });

    let mediaShow=ref(false)
    let mediaSrc=ref('')
    onUnmounted(() => {
      document.onvisibilitychange = null;
    });

    return {mediaShow,mediaSrc};
  },
};
</script>

<style scoped lang="less">
#fan {
  display: flex;
  padding: 10px;
  flex-wrap: wrap;
  .p3d {
    margin: 0 20px 10px 0;
    .text{
      position: relative;
      top: -40px;
      left: 160px;
      color:#fff;
      font-size:20px;
    }
  }
  .gua{
    margin-top: 40px;
    .text{
      width: 100px;
      height: 40px;
      line-height: 40px;
      text-align: center;
    }
  }
  .dzk{
    margin: 0 20px 10px 0;
  }
  .mediaVideo{
    width: 400px;
    height: 200px;
    text-align: center;
    .title{
      height: 20px;
      font-size: 18px;
    }
  }
}
</style>